package sdp;

public class Timer {
	
	private long lastTime;
	private long currentTime;
	private long totalTime;
	
	public Timer () {
		this.lastTime = System.currentTimeMillis();
		this.currentTime = this.lastTime;
		
		this.totalTime = 0;
	}

	public void update () {
		this.lastTime = this.currentTime;
		this.currentTime = System.currentTimeMillis();
		
		long timeElapsed = this.currentTime - this.lastTime;
		
		this.totalTime += timeElapsed;
		
		//System.out.println(this.totalTime + " - to jest czas apokalipsy");
		
	}
	
	public long getCurrentTime () {
		return this.totalTime;
	}
	
	public boolean didTimeElapse (long time, long timestamp) {
		return (this.totalTime - timestamp >= time);
	}
	
}
